package com.hcryan.djm.controller;

import com.hcryan.djm.http.request.LoginReq;
import com.hcryan.djm.pojo.entity.User;
import com.hcryan.djm.result.WebResult;
import com.hcryan.djm.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ryanwdj
 * @since 2025/2/17
 */
@RestController
@RequestMapping("/user")
@Slf4j
@Api("用户接口")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("用户注册")
    @PostMapping("/register")
    public WebResult<Void>register(@RequestBody User user){
        userService.register(user);
        return WebResult.success();
    }

    @ApiOperation("用户登陆")
    @PostMapping("/login")
    public WebResult<Void>login(@RequestBody LoginReq req){
        userService.login(req);
        return WebResult.success();
    }

}
